package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.beans.PropertyVetoException;

import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;

public class frame {

	private JInternalFrame jInternalFrame = new JInternalFrame();
	private String titulo=lang.lang.getLang(0,10), icon="/icons/000.png";
	private boolean resizable=false, closable=true, maximizable=false, minimize=true, visible=true;
	
	public JInternalFrame janela(){
        this.jInternalFrame.setVisible(this.visible);
        this.jInternalFrame.setTitle(this.titulo);
        this.jInternalFrame.setResizable(this.resizable);
        this.jInternalFrame.setClosable(this.closable);
        this.jInternalFrame.setMaximizable(this.maximizable);
        this.jInternalFrame.setLayout(new BorderLayout());
        this.jInternalFrame.setBounds(boundX(), boundY(), this.width, this.height);
        this.jInternalFrame.setSize(this.width, this.height);
        this.jInternalFrame.setIconifiable(this.minimize);
        this.jInternalFrame.setVisible(true);
        this.jInternalFrame.setFrameIcon(new ImageIcon(this.getClass().getResource(icon)));


		return this.jInternalFrame;
	}
	
    private int boundX() {
    	Component[] components = guiWSU.jDesktopPane1.getComponents();
    	int count = 0;
        for (Component c : components) {  
            if (c instanceof JInternalFrame) {
                //((JInternalFrame) c).getX();
            	count++;
            }  
        }
        int newX = (count*30);        
        return 0;//newX;
    }
    
    private int boundY() {
    	Component[] components = guiWSU.jDesktopPane1.getComponents();
    	int count = 0;
        for (Component c : components) {  
            if (c instanceof JInternalFrame) {
                //((JInternalFrame) c).getY();
            	count++;
            }  
        }
        int newY = (count*30);
        return 0;//newY;
    } 

	
	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public boolean isMinimize() {
		return minimize;
	}

	public void setMinimize(boolean minimize) {
		this.minimize = minimize;
	}

	private int x=210, y=100, width=410, height=260;

	public String getTitulo() {
		return titulo;
	}

	public void setTitulo(String titulo) {
		this.titulo = titulo;
	}

	public boolean isResizable() {
		return resizable;
	}

	public void setResizable(boolean resizable) {
		this.resizable = resizable;
	}

	public boolean isClosable() {
		return closable;
	}

	public void setClosable(boolean closable) {
		this.closable = closable;
	}

	public boolean isMaximizable() {
		return maximizable;
	}

	public void setMaximizable(boolean maximizable) {
		this.maximizable = maximizable;
	}

	public boolean isVisible() {
		return visible;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

}
